package com.ruoyi.web.admin.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysRescueStation;
import com.ruoyi.system.service.ISysRescueStationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;

/**
 * 救助站信息Controller
 * 
 * @author ruoyi
 */
@Api(tags = "救助站管理")
@RestController
@RequestMapping("/system/station")
public class SysRescueStationController extends BaseController
{
    private final ISysRescueStationService sysRescueStationService;

    public SysRescueStationController(ISysRescueStationService sysRescueStationService) {
        this.sysRescueStationService = sysRescueStationService;
    }

    /**
     * 查询救助站信息列表
     */
    @ApiOperation(value = "获取救助站列表", notes = "获取所有救助站信息")
    @PreAuthorize("@ss.hasPermi('system:station:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysRescueStation sysRescueStation)
    {
        startPage();
        List<SysRescueStation> list = sysRescueStationService.selectSysRescueStationList(sysRescueStation);
        return getDataTable(list);
    }

    /**
     * 导出救助站信息列表
     */
    @ApiOperation(value = "导出救助站信息", notes = "导出所有救助站信息数据")
    @PreAuthorize("@ss.hasPermi('system:station:export')")
    @Log(title = "救助站信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysRescueStation sysRescueStation)
    {
        List<SysRescueStation> list = sysRescueStationService.selectSysRescueStationList(sysRescueStation);
        ExcelUtil<SysRescueStation> util = new ExcelUtil<>(SysRescueStation.class);
        return util.exportExcel(list, "救助站信息数据");
    }

    /**
     * 获取救助站信息详细信息
     */
    @ApiOperation(value = "获取救助站详细信息", notes = "根据id获取救助站详细信息")
    @ApiImplicitParam(name = "id", value = "救助站ID", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
    @PreAuthorize("@ss.hasPermi('system:station:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysRescueStationService.selectSysRescueStationById(id));
    }

    /**
     * 新增救助站信息
     */
    @ApiOperation(value = "新增救助站", notes = "新增救助站信息")
    @PreAuthorize("@ss.hasPermi('system:station:add')")
    @Log(title = "救助站信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SysRescueStation sysRescueStation)
    {
        return toAjax(sysRescueStationService.insertSysRescueStation(sysRescueStation));
    }

    /**
     * 修改救助站信息
     */
    @ApiOperation(value = "修改救助站", notes = "修改救助站信息")
    @PreAuthorize("@ss.hasPermi('system:station:edit')")
    @Log(title = "救助站信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SysRescueStation sysRescueStation)
    {
        return toAjax(sysRescueStationService.updateSysRescueStation(sysRescueStation));
    }

    /**
     * 删除救助站信息
     */
    @ApiOperation(value = "批量删除救助站", notes = "批量删除救助站信息")
    @ApiImplicitParam(name = "ids", value = "救助站ID数组", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long[].class)
    @PreAuthorize("@ss.hasPermi('system:station:remove')")
    @Log(title = "救助站信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysRescueStationService.deleteSysRescueStationByIds(ids));
    }
}